<?php
require_once "ckeditor/ckeditor.php";
require_once "ckeditor/ckfinder/ckfinder.php"; //ckfinder类
include_once ("amfphp/dbconfig.php");

set_time_limit(180);

$oFCKeditor = new FCKeditor('content');

$EDITER_PATH = "http://localhost/CMS/ckeditor/";
//$EDITER_PATH = "http://www.luukschenk.nl/CMS/FCKeditor/";

$EDITER_TYPE = "Default";

CKFinder :: SetupFCKeditor($oFCKeditor, 'ckeditor/ckfinder/');

$oFCKeditor->ToolbarSet = $EDITER_TYPE;

$oFCKeditor->Width = '550';

$oFCKeditor->Height = '365';

$oFCKeditor->BasePath = $EDITER_PATH;

$oFCKeditor->Config['AutoDetectLanguage'] = false;

$oFCKeditor->Config['DefaultLanguage'] = 'en';

$id = $_REQUEST["id"];

$sql = "SELECT context FROM deschtml WHERE 1 AND id ='" . $id . "'";
$w = array ();
if (!function_exists('version_compare') || version_compare(phpversion(), '5', '<')) {
	$w = queryDB4($sql);
} else {
	$w = queryDB5($sql);
}

$info = $w[0]["context"];
//echo $info;
$oFCKeditor->Value = $info;

echo $htmlContent = $oFCKeditor->getHtml();

function queryDB5($query, $sourceRe = false) {
	$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
	$result = $mysqli->query($query);
	if ($sourceRe) {
		return $result;
	} else {
		$re = array ();
		$num_results = $result->num_rows;		
		if (is_int($num_results) && $num_results > 0) {
			for ($i = 0; $i < $num_results; $i++) {
				$row = $result->fetch_assoc();
				$re[$i] = $row;
			}
			return $re;
		} else {
			return false;
		}
	}
}
function queryDB4($query, $sourceRe = false) {
	mysql_connect(DB_HOST, DB_USER, DB_PASS);
	mysql_select_db(DB_NAME);
	$result = mysql_query($query);
	$this->insert_id = mysql_insert_id();
	if ($sourceRe) {
		return $result;
	} else {
		$re = array ();
		$num_results = mysql_num_rows($result);
		if (is_int($num_results) && $num_results > 0) {
			for ($i = 0; $i < $num_results; $i++) {
				$row = mysql_fetch_assoc($result);
				$re[$i] = $row;
			}
			return $re;
		} else {
			return false;
		}
	}
}
?>
<body style="background-color=transparent;overflow-x:hidden;overflow-y:hidden">
</body>